Skybox / Skydome

  • Steps to reproduce the Skybox from the Vulkan sample HDR:

    • Load KTX file.

      • See api_vulkan_sample.cpp->load_texture_cubemap (1202) .

    • In: in_pos  (vec3).

    • Desc Sets: Camera View and Camera Proj in the shader

    • out: out_uvw  (vec3) and out_pos  (vec3).

    textures.envmap = load_texture_cubemap("textures/uffizi_rgba16f_cube.ktx", vkb::sg::Image::Color);
    
    vkb::initializers::write_descriptor_set(descriptor_sets.object, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0, &matrix_buffer_descriptor),
    vkb::initializers::write_descriptor_set(descriptor_sets.object, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, &environment_image_descriptor),
    
    // Vertex
    layout (location = 0) in vec3 inPos;
    layout (binding = 0) uniform UBO {
        mat4 projection;           // camera.matrices.perspective;
        mat4 skybox_modelview;     // camera.view
    } ubo;
    layout (location = 0) out vec3 outUVW;
    layout (location = 1) out vec3 outPos;
    
    outUVW = inPos;
    outPos = vec3(mat3(ubo.skybox_modelview) * inPos);
    gl_Position = vec4(ubo.projection * vec4(outPos, 1.0));
    
    // Frag
    layout (binding = 1) uniform samplerCube samplerEnvMap;
    layout (location = 0) in vec3 inUVW;
    layout (location = 0) out vec4 outColor0;
    
    vec3 normal = normalize(inUVW);
    color = texture(samplerEnvMap, normal);
    // Color with manual exposure into attachment 0
    outColor0.rgb = vec3(1.0) - exp(-color.rgb * ubo.exposure);
    
  • Skybox in OpenGL .

  • See UI  and Skybox  from Kohi Engine .

    • Yea.. The engine is an insane mess.

    • The shaders are confusing and use the camera matrix and model matrix to draw UI, wtf.

    • It's impossible to find out how the graphics pipeline is created. It's an infinite wormhole.